package gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import javax.swing.border.EtchedBorder;

public class TelaSobre extends JDialog implements KeyListener {

	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	
	private JPanel panelPrincipal;
	private JLabel labelLogo;
	private JLabel labelDescricao;
	
	/**
	 * Create the frame.
	 */
	public TelaSobre(JFrame pai) {
		super(pai);
		this.addKeyListener(this);
		initialize();
	}
	
	@Override
	public void keyPressed(KeyEvent e) {
		if(e.getKeyCode()==KeyEvent.VK_ESCAPE)
			TelaSobre.this.dispose();
	}

	@Override
	public void keyReleased(KeyEvent e) {
	}

	@Override
	public void keyTyped(KeyEvent e) {
	}
	
	private void initialize(){
		setBackground(Color.WHITE);
		setUndecorated(true);
		setType(Type.UTILITY);
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 300, 200);
		setLocationRelativeTo(null);
		setAlwaysOnTop(true);
		contentPane = new JPanel();
		contentPane.setToolTipText("Pressione \"Esc\" para fechar.");
		contentPane.setBackground(Color.WHITE);
		contentPane.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, null));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		panelPrincipal= new JPanel();
		panelPrincipal.setBackground(Color.WHITE);
		contentPane.add(panelPrincipal, BorderLayout.CENTER);

		labelLogo = new JLabel("Inserir logo maior!");
		labelLogo.setHorizontalAlignment(SwingConstants.CENTER);
		labelLogo.setHorizontalTextPosition(SwingConstants.CENTER);
		
		labelDescricao = new JLabel("C\u00F3digo HTML!");
		labelDescricao.setHorizontalAlignment(SwingConstants.CENTER);
		GroupLayout gl_panel = new GroupLayout(panelPrincipal);
		gl_panel.setHorizontalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(Alignment.TRAILING, gl_panel.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_panel.createParallelGroup(Alignment.TRAILING)
						.addComponent(labelDescricao, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
						.addComponent(labelLogo, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE))
					.addContainerGap())
		);
		gl_panel.setVerticalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel.createSequentialGroup()
					.addContainerGap()
					.addComponent(labelLogo, GroupLayout.PREFERRED_SIZE, 89, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(labelDescricao, GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
					.addContainerGap())
		);
		panelPrincipal.setLayout(gl_panel);
	}

}
